﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace NetDemo
{


    public class Person
    {
        private string _name;

        public Person()
        { }

        public Person(string name)
        {
            this._name = name;
        }

        public string Name
        {
            get { return this._name; }
            set { this._name = value; }
        }

        public override string ToString()
        {
            return this._name;
        }
    }


    // The example displays the following output:
    //    Unable to instantiate a Person object with Assembly.CreateInstance(String)
    //    Instantiated a Person object whose value is 'John'






    class Program
    {
        public static double[] DeleteAdjacentLargeNumbers(double[] array)
        {
            double threshold = 1;

            for (int i = 1; i < array.Length - 1; i++)
            {
                if (Math.Abs(array[i] - array[i - 1]) > threshold)
                {
                    array = array.Where((value, index) => index != i).ToArray();
                    i--; // 因为数组已经缩小，所以索引要回退以检查现在位置的数
                }
            }
            return array;
        }



        static void Main(string[] args)
        {

            // 输入浮点数数组
            double[] input = { 47.700431, 47.700431, 41.700431, 47.700431, 47.700431 };

            // 删除相邻浮点数中大数
            double[] output = DeleteAdjacentLargeNumbers(input);

            // 输出结果
            Console.WriteLine("原数组: " + string.Join(", ", input));
            Console.WriteLine("处理后: " + string.Join(", ", output));


            //String fullName = "NetDemo.Person";
            //Assembly assem = typeof(Person).Assembly;
            //Person p = (Person)assem.CreateInstance(fullName);
            //if (!(p == null))
            //{
            //    p.Name = "John";
            //    Console.WriteLine("Instantiated a {0} object whose value is '{1}'",
            //                      p.GetType().Name, p);
            //}
            //else
            //{
            //    Console.WriteLine("Unable to instantiate a Person object " +
            //                      "with Assembly.CreateInstance(String)");
            //    // Try case-insensitive type name comparison.
            //    p = (Person)assem.CreateInstance(fullName, true);
            //    if (!(p == null))
            //    {
            //        p.Name = "John";
            //        Console.WriteLine("Instantiated a {0} object whose value is '{1}'",
            //                          p.GetType().Name, p);
            //    }
            //    else
            //    {
            //        Console.WriteLine("Unable to instantiate a {0} object.",
            //                          fullName);
            //    }
            //}


            //double data = 0.333333333333;
            //var sss = Math.Round(data, 3);
            //var ss = Math.Round(data / 1000, 3);

            //Queue<string> queue = new Queue<string>();
            //queue.Enqueue("Gary");
            //queue.Enqueue("Jack");
            //queue.Enqueue("Ryan");
            //queue.Enqueue("Kevin");
            //queue.Enqueue("Mark");
            //queue.Enqueue("Jack");
            //queue.Enqueue("Ryan");
            //queue.Enqueue("Kevin");
            //Console.Write("Count of elements = ");
            //Console.WriteLine(queue.Count);
            //Console.WriteLine("Queue...");
            //foreach (string i in queue)
            //{
            //    Console.WriteLine(i);
            //}
            //queue.Dequeue();
            //queue.Dequeue();
            //Console.WriteLine("Queue...UPDATED");
            //foreach (string i in queue)
            //{
            //    Console.WriteLine(i);
            //}
            //Console.Write("Count of elements (updated) = " + queue.Count);
            //queue.Clear();
            //Console.Write("\nCount of elements (updated AGAIN) = ");
            //Console.WriteLine(queue.Count);


        }
    }
}
